package com.GetIp;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.ServerSocket;
import java.net.Socket;

public class Main103 {
    public static void main(String[] args){
        try{
            ServerSocket ss = new ServerSocket(8080);
            System.out.println("服务器启动");
            Socket s = ss.accept();
            System.out.println("客户端:"+s.getInetAddress().getLocalHost()+"已连接");
            BufferedReader br = new BufferedReader(new InputStreamReader(s.getInputStream()));
            String mess= br.readLine();
            System.out.println("客户端说:"+mess);
            BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(s.getOutputStream()));
            bw.flush();
        }catch (IOException e){
            e.printStackTrace();
        }
    }
}
